﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using RenAi.Medical.Model;

namespace RenAi.Medical.DAL
{
    public class NewDAL
    {
        /// <summary>
        /// 获取新闻资讯信息
        /// </summary>
        /// <returns></returns>
        public DataTable GetNewsAll()
        {
            string sql = "select news_id,news_title,News_Content,news_time,newstype_name from news n join NewsType nt on n.NewsType_Id=nt.NewsType_Id";
            return DBhelper.GetTable(sql);
        }
        /// <summary>
        /// 删除新闻
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DelNew(string news_id)
        {
            int i = DBhelper.NonQuery(string.Format("delete from news where news_id='{0}'", news_id));
            return i;
        }
        /// <summary>
        /// 根据id获取新闻资讯信息
        /// </summary>
        /// <param name="news_id"></param>
        /// <returns></returns>
        public DataTable GetNewsById(int news_id)
        {
            string sql = "select * from news where news_id=" + news_id + "";
            return DBhelper.GetTable(sql);
        }
        /// <summary>
        /// 获取新闻类型信息
        /// </summary>
        /// <returns></returns>
        public DataTable GetNewtypeAll()
        {
            string sql = "select * from NewsType";
            return DBhelper.GetTable(sql);
        }
        //public int AddNews(News n)
        //{
        //    string sql = "insert into news values('" + n.News_Title + "','" + n.News_Content + "','" + n.News_Time + "','" + n.NewType_Id + "')";
        //}
    }
}
